package com.factory.iamp.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        //跨域路径
        registry.addMapping("/**")
                //跨域源
                .allowedOriginPatterns("*")
                //跨域方法
                .allowedMethods("POST", "GET", "PUT", "DELETE", "OPTIONS")
                //允许头部设置
                .allowedHeaders("*")
                //发送cookie
                .allowCredentials(true);
    }
}
